$(document).ready(function () {
    var oAll = $("#Boy tr").length;
    var oFirst = $('#Boy tr:first-child').length;
    if (oFirst) {
        $('#first').html(oFirst);
        $('#last').html(oAll);
        $('#all').html(oAll)
    } else {
        $('span').html('没有订单记录！');
    }

});

// 门票管理全选
(function () {
    var $SelectAllCB = $('#m-select-all');
    var $CheckBoxArr = $('#manage-form table input[type=checkbox]').slice(1);
    selectAll({selectAllCB: $SelectAllCB, checkBoxArr: $CheckBoxArr});
})();

// 我的购物全选
(function () {
    var $SelectAllCB = $('#c-select-all');
    var $CheckBoxArr = $('#cart-form table input[type=checkbox]').slice(1);
    selectAll({selectAllCB: $SelectAllCB, checkBoxArr: $CheckBoxArr});
})();

/**
 * 选择全部
 */
function selectAll(obj) {
    var selectAllCB = obj.selectAllCB;
    var checkBoxArr = obj.checkBoxArr;
    selectAllCB.on('change', function () {
        if(selectAllCB.prop('checked')){
            checkBoxArr.prop('checked', true);
        }else {
            checkBoxArr.prop('checked', false);
        }
    })
}